import { defineStore } from 'pinia'
import axios from 'axios'

interface User {
  id: number,
  name: string
}
export const useTagCenter = defineStore('tagCenter', {
  state: () => {
    return {
      tableData: <User[]>([])
    }
  },
  actions: {
    async getTags() {
      const response = await axios.get("http://192.168.1.3:8000/admin/getTags")
      return response
    },
    async createTags(token: string, name: string) {
      const response = await axios.post("http://192.168.1.3:8000/admin/createTag",
        { name },
        {
          headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' },
        },
      )
      return response
    },
    async deleteTags(token: string, id: number) {
      const response = await axios.delete(`http://192.168.1.3:8000/admin/deleteTag/${id}`,
        { headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' } }
      )
      return response
    }
  }
})